package com.sergio.accounting.dto;

import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 记账记录数据传输对象
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RecordDTO {

    private Long id;

    // userId 由后端从JWT token中自动获取，不需要前端传递
    private Long userId;

    @NotBlank(message = "记录类型不能为空")
    private String recordType;

    @NotNull(message = "金额不能为空")
    @DecimalMin(value = "0.01", message = "金额必须大于0")
    private BigDecimal amount;

    @NotNull(message = "分类ID不能为空")
    private Long categoryId;
    
    // 账户ID（可为空，表示不计入账户）
    private Long accountId;

    @Size(max = 500, message = "备注长度不能超过500个字符")
    private String note;

    @NotNull(message = "记录日期不能为空")
    private LocalDate recordDate;

    // 用于返回的字段
    private String categoryName;
    private String categoryIcon;
    private String categoryType;
}
